<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <main>
      <a style="color: red" href="http://www.hdcmds.sff.com">后盾人</a>
      <a style="color: black" href="http:zzks.com">zks</a>
      <a href="http://yahoo.com">雅虎</a>
      <h4>https://www.hdcmds.com</h4>
    </main>
    <script>
      const main = document.querySelector("main");

      const reg =
        /<a .*?href="http?:(?:\/\/)?(www\.)?(\w+\.)+(com|cn)">([\S]+?)<\/a>/gi;
      let arr = [];
      while ((res = reg.exec(main.innerHTML))) {
        arr.push(res);
      }
      console.log(arr);

      main.innerHTML = main.innerHTML.replace(reg, (v, ...args) => {
        args[1] += "s";
        args[2] = args[2] || "www.";
        return `<a href=${args[0]}${args[1]}${args[2]}>${args[3]}</a>`;
      });
    </script>
  </body>
</html>
